<!DOCTYPE html>
<title>Load a video with an infinite duration. Start playback and ensure video.currentTime is less than video.buffered.end(0) upon first timeupdate.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");

    video.ontimeupdate = t.step_func_done(function() {
        video.ontimeupdate = null;
        video.pause();

        assert_equals(video.duration, Infinity);
        assert_greater_than_equal(video.buffered.start(0), 0);

        // 10 seconds chosen arbitrarily as it's larger than the duration, but
        // small enough to test for overflow of arithmetic performed on the
        // infinite duration.
        assert_less_than(video.buffered.end(0), 10);
        assert_less_than_equal(video.currentTime, video.buffered.end(0));
    });

    video.onloadeddata = t.step_func(function() {
        video.onloadeddata = null;

        // We may not have video.buffered.length at this time, but if we do it
        // should be between 0 and some value less than infinity.
        if (video.buffered.length > 0) {
            assert_greater_than_equal(video.buffered.start(0), 0);
            assert_not_equals(video.buffered.end(0), Infinity);
        }
        assert_equals(video.currentTime, 0);
        assert_equals(video.duration, Infinity);
        video.play();
    });

    video.src = "resources/test-live.webm";
});
</script>